<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
        <meta http-equiv="X-UA-Compatible" content="IE=8" />
        <title>WTT: Way of The Temple</title>
        <meta name="keywords" content=""    />
        <meta name="description" content="" />
        <link   rel="stylesheet" href="css/styles.css"      type="text/css" media="screen" />
		<link   rel="stylesheet" href="css/jquery-ui.css"   type="text/css" media="screen" />
		<link   rel="stylesheet" href="css/alertify.css"    type="text/css" media="screen" />

        <script type="text/javascript" src="lib/jq.js"></script>
		<script type="text/javascript" src="lib/jquery-ui.js"></script>
        <script type="text/javascript" src="lib/jstorage.js"></script>
		<script type="text/javascript" src="lib/Melon.js"></script>
		<script type="text/javascript" src="lib/alertify.js"></script>
   </head>
	
    <body background="css/chinesetemple1.jpg" bgcolor="#333333" style="margin:0;padding:0">
		<script>
			function chama_loding(){
				$( "#dialogoLoding" ).dialog({
					autoOpen: false,
					height: 150,
					width: 300,
					modal: true,
				});
				
				$( "#dialogoLoding" ).dialog( "open" );
			}
			function include(filename)
			{
				var head = document.getElementsByTagName('head')[0];
				var script = document.createElement('script');
				script.src = filename;
				script.type = 'text/javascript';

				head.appendChild(script)
			}
            var socket;
            window.onReady(function onReady() {
                $.jStorage.flush();
				socket = jsApp.getSocket();
				//////////////////////////
				//login                //
				var loginFun =  function (data) {
                    if(data[0][0].msg != undefined){
                        alert(data[0][0].msg);
                    }else{
                        var d0 = data[0][0];
                        console.log("loggin in with userId "+d0.userId +" and session id "+d0.sessionId);
                        $.jStorage.set("userData", d0);
                        $("#divLogin").hide();
                        $("#footer_bot").hide();
                        $("#logo").hide();
                        jsApp.onload();
                    }
                }
                socket.on('loginok',loginFun);
				//////////////////////////////////
				
				///////////////////////////////////
				// msg functions               ///
				var msgFun = function(data) {
                    alert(data.msg);
					//REMOVING LISTENER
					//jsApp.destroy('message', msgFun);
                }
                socket.on('message', msgFun);
				/////////////////////////////////
                //////// DEBUG MODE
                //$("#divLogin").hide();
                //$.jStorage.set("userData", {userId: 4, sessionId:34});
                //jsApp.onload();
            });

            function go(){
               socket = jsApp.getSocket();
               var user =  $("#username").val();
               var pass = $("#password").val();
			   
               socket.emit("login",  { p1:user,p2:pass });
			   chama_loding();
            }
			
			function alert(msg){
				//console.log(msg);
				alertify.log(msg);
				//alertify.error(msg);
				//alertify.log(msg);
				//alertify.success(msg);

			}
			
			function onClickSelection(dest,type) {
				var checkbox = $(dest).find(':'+type);
				checkbox.prop('checked',!checkbox.prop("checked"));
			}

			function toolTip(Dest){
				var title = $(Dest).attr("title");
				alertify.log(title);
			}

			include("lib/socket.js");
			include("Screens/PlayScreen.js");
			include("Screens/TitleScreen.js");
			include("Screens/OutWorldScreen.js");
			include("Entity/Unit.js");
			include("Resources.js");
			include("App.js");
			include("UnityAI.js");
			include("Screens/ActionMenu.js");
			include("Screens/TempleTimeOut.js");
			include("Screens/ResourcesHUD.js");
			include("Screens/BuildArea.js");
			include("Screens/BuildingHUD.js");
			include("Screens/ProgressBar.js");
			include("Screens/ColectAlert.js");
			include("Screens/BuildingDetail.js");
			include("Screens/WorldNames.js");
			include("Screens/WorldBuildingOptions.js");
			
		</script>
    	<div id="grad_bg">&nbsp;</div>
		<div id="wrap">	
			<div id="logo">
				<h1><a href="#"><img src="css/logo.png"/></a></h1>
                <br><br>

			</div> <!-- FIM ID = LOGO -->

			<div id="content_bg">
				<div id="header" height="320">
					<div id="wrapper" align="center">

						<div id="screen"></div>
                        <br><br><br><br><br>
					    <div id="divLogin" class="login-form">
							<br /><br />
							<h1>Go into your Kingdom</h1>
							<input type="text" name="username" id="username" placeholder="username">
							<input type="password" name="password" id="password" placeholder="password">
							<input type="button" id="go" value="Sign In" onclick='go();'>
						</div>
					</div><!-- FIM ID = WRAPPER -->
					
				</div><!-- FIM ID = HEADER -->	
				<br><br><br><br>		
			</div> <!-- FIM ID = CONTENT BD -->
			
			<div id="footer_bot">
				<p>Copyright  2013. <!-- Do not remove -->Designed by <a href="#">Ryba</a>, coded by <a href="#">Ryba</a><!-- end --></p>
		        <p><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a> | <a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional"><abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a> | <a href="http://jigsaw.w3.org/css-validator/check/referer" title="This page validates as CSS"><abbr title="Cascading Style Sheets">CSS</abbr></a></p>
			</div>
		</div> <!-- FIM ID = WRAP -->
	<!-- PARTE DOS DIALOGOS -->
		<div name="dialogoLoding" id="dialogoLoding" title="Please Wait..." style="display:none">
			<form>
				<fieldset>
				  <div class="box">
						<h1>LOADING...</h1>
				 </div>
				</fieldset>
			</form>
		</div>
	<!-- FIM DOS DIALOGOS --->
    </body>
</html>
